using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.IO;

namespace IGlobalist.Cms
{
    public partial class __EditorCss : System.Web.UI.Page
    {

        protected string Filename
        {
            get
            {
                string filename = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, ddlFile.SelectedValue);
                return filename;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {


                BindContentFile();

            }
        }

        protected void BindContentFile()
        {
            String text = "";
            if (File.Exists(Filename))
            {
                StreamReader sreader = new StreamReader(Filename);
                text = sreader.ReadToEnd();
                sreader.Close();
            }
            txtCSS.Text = text;
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            TextWriter swriter = new StreamWriter(Filename);
            String text = txtCSS.Text;
            swriter.Write(text);
            swriter.Flush();
            swriter.Close();
            swriter.Dispose();
            
        }

        protected void ddlFile_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindContentFile();
        }
    }
}
